UNPKG

mongoku

Version:

[![CI](https://github.com/huggingface/Mongoku/actions/workflows/ci.yml/badge.svg)](https://github.com/huggingface/Mongoku/actions/workflows/ci.yml)

19 lines (14 loc) 607 B
import { getMongo } from "$lib/server/mongo"; import type { PageServerLoad } from "./$types"; export const load: PageServerLoad = async ({ params }) => { const mongo = await getMongo(); const client = mongo.getClient(params.server); const db = client.db(params.database); const mappings = await client.getMappings(params.database, params.collection, { forceRefresh: true }); // Get list of all collections in the database for the dropdown const allCollections = (await db.listCollections().toArray()).map((c) => c.name).sort(); return { mappings, availableCollections: allCollections, }; };